#!/usr/bin/php
<?
// $Id: console.php 73 2010-12-26 19:17:36Z MartinS $


foreach ($argv as $arg) {
  if (substr($arg, 0, 2) == "--") {
    $argument[substr($arg, 2)] = 1;
  } elseif (substr($arg, 0, 1) == "-") {
    $oArg = substr($arg, 1);
  } else {
    switch ($oArg) {
      case "P": case "A": case "T":
        $argument["pages"][] = $arg;
        break;
      default:
      $argument[$oArg][] = $arg;
    }
  }
}
// Script copied from console-doibot.php but not modified; of no use yet!

error_reporting(E_ALL^E_NOTICE);
$accountSuffix='_1'; // This must be specified before including boot.php
$htmlOutput = false; // This must be specified before including boot.php
include("boot.php");
include("inc/children.php");
$editInitiator = '[c' . (revisionID() + 1) . '&beta;]';
$ON = true; // Override later if necessary

print "\nGetting a list of all taxa: ";
$all_pages = getPrefixIndex("Taxonomy/", 10, "Taxonomy/" . $argument["start"][0]);
print count($all_pages) . " pages in total";
print "\nGetting taxa that are already converted: ";
$already_done = getPrefixIndex("Taxobot/children/", 2, "Taxobot/children/" );
print count($already_done) . " taxa already have children templates.\n";
foreach ($already_done as $taxon) {
  $done_taxa[] = substr($taxon, 22);
}

foreach ($all_pages as $page) {
  $title = substr($page, 18);
  if (true || !in_array($title, $done_taxa)) {
      print (writeChildren($title)
            ? "\nWritten to User:Taxobot/children/$title"
            : "\nCouldn't write to User:Taxobot/children/$title");
  } else print ".";
}

die ("\n\n === stop here. === \n");

#$STOP = true;
$ON = false; // Uncomment this line to set the bot onto the Zandbox, switched off.

$page = "User:taxobot/Sandbox";  // Leave this line as is.  It'll be over-written when the bot is turned on.
if ($ON) {

}
include("expand.php");// i.e. GO!

print "\n Done. \n";
